//
//  main.m
//  Film
//
//  Created by dllo on 16/3/5.
//  Copyright © 2016年 Apon. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "Film.h"
int main(int argc, const char * argv[]) {
 

#pragma mark - 引入文件
    NSData *data = [NSData dataWithContentsOfFile:@"/Users/dllo/Desktop/李劲成/OC语言/Film/Film/news.txt" ];
    id result = [NSJSONSerialization JSONObjectWithData: data options:NSJSONReadingMutableContainers error:nil];
 
    
#pragma mark - 接收
 @autoreleasepool {
    /** news数组 */
    NSMutableArray *newS = [result objectForKey:@"news"];
    /** film对象的数组 */
    NSMutableArray *arrayOfFilm = [NSMutableArray array];

    /** 遍历news数组 创建Film对象, 将title, picUrl, summary以字符串形式接收 , 将Film对象放入数组当中 */
    for (NSDictionary *dic in newS) {
        NSMutableDictionary *dictionaryOfFilm = [NSMutableDictionary dictionary];
        [dictionaryOfFilm setObject:[dic objectForKey:@"title"] forKey:@"title"];
        [dictionaryOfFilm setObject:[dic objectForKey:@"picUrl"] forKey:@"picUrl"];
        [dictionaryOfFilm setObject:[dic objectForKey:@"summary"] forKey:@"summary"];
        Film *film = [Film filmWithWithDictionary:dictionaryOfFilm];
        [arrayOfFilm addObject:film];
        
    }
  
    NSLog(@"%@", [arrayOfFilm debugDescription]);

}
    
    NSLog(@"over");
   
    
    
    return 0;
        
}
